/*******************************************************************************
 * Package: com.hngtrust.iir.report.controller
 * Type:    ReportReportController
 * Date:    2021/9/18 15:01
 *
 * Copyright (c) 2021 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.material.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.iir.dto.ReqDTO;
import com.hngtrust.iir.material.controller.dto.*;
import com.hngtrust.iir.material.dto.MaterialCollectAndPathDTO;
import com.hngtrust.iir.material.dto.MaterialCommentDTO;
import com.hngtrust.iir.material.dto.MaterialRightDTO;
import com.hngtrust.iir.material.dto.MaterialRightUserOrDepartDTO;
import com.hngtrust.iir.material.service.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 内部资料-我的（收藏、评论、日志、权限）
 *
 * @author Chaidd
 * @date 2021/11/10 15:01
 */
@Slf4j
@RestController
@RequestMapping("/material-my")
@Api(tags = "内部资料-我的（收藏、评论、日志、权限）")
public class MaterialMyController {

    @Autowired
    private MaterialCollectionService materialCollectionService;
    @Autowired
    private MaterialCommentBacService materialCommentBacService;
    @Autowired
    private MaterialLogBacService materialLogBacService;
    @Autowired
    private MaterialRightBacService materialRightBacService;
    
    @ApiOperation(value = "内部资料-我的收藏列表", notes = "内部资料-我的收藏列表")
    @PostMapping("/list-collect")
    public ResponseInfo<PageResult<MaterialCollectAndPathDTO>> listCollect(
            @ApiParam("内部资料-我的收藏列表") @Valid @RequestBody ReqDTO<MaterialCollectQueryVO> reqDTO){
        log.info("MaterialCollectionController.listCollect start...");
        PageResult<MaterialCollectAndPathDTO> pageResult = materialCollectionService.listCollect(reqDTO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部资料-删除收藏列表", notes = "内部资料-删除收藏列表")
    @PostMapping("/delete-collect")
    public ResponseInfo<MaterialCollectDeleteVO> deleteCollect(
            @ApiParam("内部资料-删除收藏列表") @Valid @RequestBody MaterialCollectDeleteVO reqDT){
        log.info("MaterialCollectionController.deleteCollect start...");
        materialCollectionService.deleteCollect(reqDT);
        return new ResponseInfo(reqDT);
    }
    
    @ApiOperation(value = "内部资料-新增收藏列表", notes = "内部资料-新增收藏列表")
    @PostMapping("/add-collect")
    public ResponseInfo<MaterialCollectInsertVO> addCollect(
            @ApiParam("内部资料-新增收藏列表") @Valid @RequestBody MaterialCollectInsertVO reqDT){
        log.info("MaterialCollectionController.addCollect start...");
        materialCollectionService.addCollect(reqDT);
        return new ResponseInfo(reqDT);
    }
    
    @ApiOperation(value = "内部资料-我的评论列表", notes = "内部资料-我的评论列表")
    @PostMapping("/list-comment")
    public ResponseInfo<MaterialCommentDTO> listComment(
            @ApiParam("内部资料-我的评论列表") @Valid @RequestBody MaterialCommentQueryVO materialCommentQueryVO){
        log.info("MaterialCommentController.listComment start...");
        List<MaterialCommentDTO> list = materialCommentBacService.listComment(materialCommentQueryVO);
        return new ResponseInfo(list);
    }
    
    
    @ApiOperation(value = "内部资料-我的评论新增", notes = "内部资料-我的评论新增")
    @PostMapping("/add-comment")
    public ResponseInfo<MaterialCommentInsertVO> addComment(
            @ApiParam("内部资料-我的评论列表") @Valid @RequestBody MaterialCommentInsertVO materialCommentInsertVO){
        log.info("MaterialCommentController.addComment start...");
        materialCommentBacService.addComment(materialCommentInsertVO);
        return new ResponseInfo(materialCommentInsertVO);
    }
    
    @ApiOperation(value = "内部资料-研报操作日志列表", notes = "内部资料-研报操作日志列表")
    @PostMapping("/list-log")
    public ResponseInfo<PageResult<MaterialLogDTO>> listLog(
            @ApiParam("内部资料-研报操作日志列表") @Valid @RequestBody ReqDTO<MaterialLogQueryVO> reqDTO){
        log.info("MaterialLogBacController.listLog start...");
        PageResult<MaterialLogDTO> pageResult = materialLogBacService.listLog(reqDTO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部资料-研报权限表列表", notes = "内部资料-研报权限表列表")
    @PostMapping("/list-right")
    public ResponseInfo<MaterialRightDTO> listRight(
            @ApiParam("内部资料-研报权限表列表") @Valid @RequestBody MaterialRightQueryVO materialRightQueryVO){
        log.info("MaterialRightBacController.listRight start...");
        List<MaterialRightDTO> pageResult = materialRightBacService.listRight(materialRightQueryVO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部资料-修改研报权限表", notes = "内部资料-修改研报权限表")
    @PostMapping("/update-right")
    public ResponseInfo<MaterialRightUpadteVO> updateRight(
            @ApiParam("内部资料-修改研报权限表") @Valid @RequestBody MaterialRightUpadteVO materialRightUpadteVO){
        log.info("MaterialRightBacController.updateRight start...");
        materialRightBacService.updateRight(materialRightUpadteVO);
        return new ResponseInfo(materialRightUpadteVO);
    }
    
    @ApiOperation(value = "内部资料-权限部门或人员搜索", notes = "内部资料-权限部门或人员搜索")
    @PostMapping("/query-userordepartment")
    public ResponseInfo<List<MaterialRightUserOrDepartDTO>> queryUserOrDepartment(
            @ApiParam("内部资料-权限部门或人员搜索") @Valid @RequestBody MaterialRightUserOrDepartVO materialRightUserOrDepartVO){
        log.info("MaterialRightBacController.queryUserOrDepartment start...");
        List<MaterialRightUserOrDepartDTO> materialRightUserOrDepartDTOS = materialRightBacService.queryUserOrDepartment(materialRightUserOrDepartVO);
        return new ResponseInfo(materialRightUserOrDepartDTOS);
    }
    
}
